home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9018 < prev    next >
Encoding:
Text File  |  1996-08-05  |  957 b   |  46 lines

  1. Path: news.glo.be!usenet
  2. From: sclaeys@glo.be (Sven Claeys)
  3. Newsgroups: comp.lang.c
  4. Subject: Input into array of strings?
  5. Date: Thu, 07 Mar 1996 23:25:20 GMT
  6. Organization: Globe
  7. Message-ID: <4hnv1e$o7n@rhea.glo.be>
  8. NNTP-Posting-Host: ip139.z03.glo.be
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Hi,
  12.  
  13. I've got a some kind of problem reading into arrays of strings. I'm a
  14. bit rusty in C or C++, it's been a while, so please be patient with
  15. me.
  16.  
  17. here we go:
  18.  
  19. i've got a structure
  20.  
  21. struct ImmoData
  22. {
  23.    char code[3][5];
  24.    ....
  25. }....;
  26.  
  27. now i want to read data from a file with fgets(...) into this array.
  28.  
  29. I've tried
  30.    for (i=0; i<5; i++)
  31.        fgets(code[i],....);
  32. or
  33.    for (i=0; i<5; i++)
  34.        fgets((char*) code[i], ...);
  35.  
  36. but none of these seem to work. As i'm debugging the first code is
  37. read correct, but the second is appended to the first and is also read
  38. into the second, and so on.
  39.  
  40. Could anyone help me with this strange phenomenon?
  41.  
  42.  
  43. Greetz.
  44. Sven.
  45.  
  46.